{% extends 'base.html' %}
{% import 'bootstrap/wtf.html' as wtf %}

{% block content %}
    <div class="container">
        <div class="row">
            <div class="col-xs-6 col-md-offset-3">
        <form method="POST" onsubmit="return check()">
            {{ form.hidden_tag() }}
            <div class="form-group">
                {{ form.item.label }}:{{ form.item(class="form-control", placeholder="事项", value=daily.item) }}
            </div>
            <div class="form-group">
                {{ form.detail.label }}:{{ form.detail(class="form-control", placeholder="事项详情", value=daily.detail) }}
            </div>
            <div class="form-group">
               {{ form.status.label }}:{{ form.status(class="form-control", placeholder="状态", value=daily.status) }}
            </div>
            <div class="form-group">
               {{ form.finsh_time.label }}:{{ form.finsh_time(class="form-control", placeholder="计划完成时间", value=daily.finsh_time) }}
            </div>
            <div class="form-group">
                {{ form.submit(class="btn btn-primary") }}
            </div>

        </form>
			</div>
        </div>
    </div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script type="text/javascript">
    function DatePicker(beginSelector){
            // 仅选择日期
            $(beginSelector).datepicker(
            {
            	language:  "zh-CN",
            	autoclose: true,
            	startView: 0,
            	format: "yyyy-mm-dd",
            	clearBtn:true,
            	todayBtn:false,

            })
    };


    DatePicker("#finsh_time");
    
    function check() {
        var data = $("#status").val();
        console.log(data);
        //return false;
        var regPos = /^\d+$/;
        var tmp = parseInt(data.substring(0,data.length-1))
        if (data.charAt(data.length-1) == "%" && !data.startsWith("0") && !((data.substring(0,data.length-1)).endsWith("-")) && regPos.test(tmp) && tmp <=100 && tmp>0){
        return true;
            
        }else{
            $.alert({
                type:'red',
                title: '系统提示',
                content: "状态格式不对!",
            });
            return false;
        }
    }

    </script>
{% endblock %}
